//
//  TTTabBar.h
//  Tint
//
//  Created by Kevin Wu on 4/13/12.
//  Copyright (c) 2012 Telligenty. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "TTCore.h"
#import "TTAdditions.h"

#import "TTTab.h"


typedef enum {
    TTTabBarTabAlignmentTop = 0, 
    TTTabBarTabAlignmentCenter, 
    TTTabBarTabAlignmentBottom
} TTTabBarTabAlignment;


@protocol TTTabBarDelegate;


@interface TTTabBar : UIView<UIScrollViewDelegate> {
    
    id<TTTabBarDelegate> _delegate;
    NSArray *_tabs;
    
    BOOL _customTabSize;
    TTTabBarTabAlignment _tabAlignment;
    UIEdgeInsets _edgeInsets;
    CGFloat _spacing;
    
    TTTab *_selectedTab;
    
    UIImageView *_backgroundImageView;
    UIScrollView *_containerView;
}

@property(nonatomic, assign) id<TTTabBarDelegate> delegate;
@property(nonatomic, retain) NSArray *tabs;

@property(nonatomic, assign) BOOL customTabSize;
@property(nonatomic, assign) TTTabBarTabAlignment tabAlignment;
@property(nonatomic, assign) UIEdgeInsets edgeInsets;
@property(nonatomic, assign) CGFloat spacing;

@property(nonatomic, retain) UIImage *backgroundImage;


- (id)initWithTabs:(NSArray *)tabs;

- (void)update;
- (void)updateByTab:(TTTab *)tab;
- (void)updateByTabAtIndex:(NSUInteger)index;
- (void)updateCurrentTab:(TTTab *)currentTab selectedTab:(TTTab *)selectedTab;

- (void)selectTab:(TTTab *)tab;
- (void)selectTabAtIndex:(NSUInteger)index;

- (void)layoutTabs;

- (TTTab *)selectedTab;
- (NSUInteger)selectedIndex;

- (void)didSelectTabAtIndex:(NSUInteger)index;

@end


@protocol TTTabBarDelegate <NSObject>
@optional
- (void)tabBar:(TTTabBar *)tabBar didSelectTabAtIndex:(NSUInteger)index;
@end
